#ifndef _ACTIVITY_CONFIG_H_
#define _ACTIVITY_CONFIG_H_

#include "Define.h"
#include "msg_public.h"
#include "pugixml.hpp"
#include <map>
#include <vector>

struct ActivityAward
{
    int id;
    publicproto::AwardInfo award;
    int dailyLimit;
    int curGet;
    int prob;
    u64 lastGetTime; // 奖励最后发送时间
};

struct ActivityItem
{
    s32 activityid;
    s32 gameid;

    s32 condition1;
    s32 condition2;
    s32 condition3;
    s32 condition4;
    s64 condition5;
    s64 condition6;
    s64 condition7;
    s64 condition8;

    // 奖励发放方式 1:所有配置奖励发送 2:概率抽取
    s32 getawardtype;
    // 奖励自动、手动获得
    s32 autoaward;

    u64 tbegin;
    u64 tend;

    std::vector<ActivityAward> awards;

    // 抽奖奖励的默认奖励
    s32 defaultAwardIdx;

    void DumpConditions(std::vector<s64> &conns) const
    {
        conns.clear();
        conns.push_back(condition1);
        conns.push_back(condition2);
        conns.push_back(condition3);
        conns.push_back(condition4);
        conns.push_back(condition5);
        conns.push_back(condition6);
        conns.push_back(condition7);
        conns.push_back(condition8);
    }
};

class CActivityConfigManager
{
    SINGLETON_CLASS_DEFINE(CActivityConfigManager);
public:
    void Load(const char *file);
    ActivityItem* FindActivity(s32 activityid);
    std::map<s32, ActivityItem>& GetAllActivity() { return m_activity; } 
    void GetAwards(s32 activityid, std::vector<publicproto::AwardInfo> &awards);
    void GetAwards(ActivityItem &activity, std::vector<publicproto::AwardInfo> &awards);

private:
    void _LoadAwards(ActivityItem &item, pugi::xml_node &awards);

private:
    std::map<s32, ActivityItem> m_activity;
};

#endif

